<?php
/**
 * Created by PhpStorm.
 * User: frankpian
 * Date: 17-12-1
 * Time: 上午10:39
 */

use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Regex as RegexValidator;
use Phalcon\Validation\Validator\Between;
use Phalcon\Validation\Validator\StringLength;
use Qcloud_cos\Cosapi;

class FactoryController extends CloudControllerBase
{


    /******************************    相机检校    ***********************************************************/
    public function cameraCalibrationAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $action = $this->getRequestAction();
        switch ($action) {
            case  $this::REQUEST_ACTION_DELETE: {
            };
                break;
            case  $this::REQUEST_ACTION_LIST: {
                $table = "(
SELECT C.id, u.username as upload_user_id, C.camera_id, C.report_id, C.camera_lens_id, m.name AS cameraModel, C.is_checked, C.qualified, C.picture1_url, C.picture2_url, C.uploaded_at, plane.uas_serial_id, CONCAT('{$this->host["page_host"]}/report/getXml?id=',C.id) as xml_url, CONCAT('{$this->host["page_host"]}/report/getword?id=',C.id) as word_url, C.check_project_url, C.calibration_result_url FROM camera_check AS C
LEFT JOIN plane ON C.plane_id=plane.id
LEFT JOIN camera_model AS m ON C.cameraModel_id=m.id 
LEFT JOIN fos_user_user as u ON C.upload_user_id=u.id
)";
                $this->postQueryByPage(array(
                    "id" => "ID",
                    "upload_user_id" => "上传用户id",
                    "uas_serial_id" => "飞机id",
                    "cameraModel" => "相机型号",
                    "camera_id" => "相机id",
                    "picture1_url" => "图片1",
                    "picture2_url" => "图片2",
                    "uploaded_at" => "图片上传时间",
                    "is_checked" => "已检校",
                    "qualified" => "检校合格",
                    "xml_url" => "下载xml文件",
                    "check_project_url" => "检校项目文件",
                    "calibration_result_url" => "检验报告",
                    "word_url" => "下载word文件",
                ), $table
                    , array(
                        ["id", "="],
                        ["camera_id", "like", "%", "%"],
                        ["qualified", "="],
                        ["is_checked", "="],
                        ["upload_user_id", "="],
                        ["uas_serial_id", "like", "%", "%"],
                        ['uploaded_at_start', '>=', '', '', "uploaded_at"],
                        ['uploaded_at_end', '<=', '', '', "uploaded_at"]
                    ),"uploaded_at desc","id");
            };
                break;
        }
        $this->view->setVars(array("planeTypeList" => $this->getPlaneModelInfo()

            )

        );
    }
    
    public function addCameraCalibrationAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        
        $this->view->setVars(array(
                "cameraTypeList" => $this->getCameraTypeInfo()));
    }
    
    public function addCameraCalibrationDoAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $user = $this->getMonitorLoginUser();
        
        $this->checkRequestParams(array(
                array(
                        "key" => "camera_id",
                        "type" => "presence",
                        "message" => "相机id为空",
                ),
                array(
                        "key" => "camera_lens_id",
                        "type" => "presence",
                        "message" => "镜头id为空",
                ),
        ));
        $camera_id = $this->getPost("camera_id");
        $camera_lens_id = $this->getPost("camera_lens_id");
        $cameraModel_id = $this->getPost("cameraModel_id");
        $picture1_url = $this->getPost("picture1_url");
        $picture2_url = $this->getPost("picture2_url");
        $picture3_url = $this->getPost("picture3_url");
        
        file_put_contents("./log_" . date("Y-m-d") . ".txt","\n".date("H:i:s", time()).':'.__METHOD__.':'."add camera_id:$camera_id, camera_lens_id:$camera_lens_id, cameraModel_id:$cameraModel_id\r\n", FILE_APPEND);
        
        $time = date('Y-m-d H:i:s');
        $this->insert('camera_check', array('camera_id'=>$camera_id,
                'camera_lens_id'=>$camera_lens_id,
                'report_id'=>$camera_id.'-'.$camera_lens_id,
                'cameraModel_id'=>$cameraModel_id,
                'uploaded_at'=>$time,
                'checked_at'=>$time,
                'cloud_user_id'=>$user->userId,
                'picture1_url'=>$picture1_url,
                'picture2_url'=>$picture2_url,
                'picture3_url'=>empty($picture3_url)?null:$picture3_url));        
        
        $this->returnSuccess("更新成功");
    }
    
    
    
    public function editCameraCalibrationAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        
//         $id = $this->getPost("camera_check_id");
        $id = $this->getQuery("id");
        
        $cameraCheck = $this->fetchOne("select * from camera_check where id = $id");
        $uas_serial_id = "";
        if($cameraCheck['plane_id']){
            $uas_serial_id = $this->fetchColumn("select uas_serial_id from plane where id = '{$cameraCheck['plane_id']}'");
        }
        
        file_put_contents("./log_" . date("Y-m-d") . ".txt","\n".date("H:i:s", time()).':'.__METHOD__.':'."sql:select * from camera_check where id = $id\r\n", FILE_APPEND);
        
        $this->view->setVars(array(
                "cameraTypeList" => $this->getCameraTypeInfo(),
                "cameraCheck" => $cameraCheck,
                "uas_serial_id" => $uas_serial_id
        ));
    }
    
    public function editCameraCalibrationDoAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $user = $this->getMonitorLoginUser();
        
        $this->checkRequestParams(array(
                array(
                        "key" => "camera_id",
                        "type" => "presence",
                        "message" => "相机id为空",
                ),
                array(
                        "key" => "camera_lens_id",
                        "type" => "presence",
                        "message" => "镜头id为空",
                ),
        ));
        
        $id = $this->getPost("id");
        $camera_id = $this->getPost("camera_id");
        $camera_lens_id = $this->getPost("camera_lens_id");
        $cameraModel_id = $this->getPost("cameraModel_id");
        $uas_serial_id = $this->getPost("uas_serial_id");
        $qualified = $this->getPost("qualified");
        
        $time = date('Y-m-d H:i:s');
        
        $result['camera_id'] = $camera_id;
        $result['camera_lens_id'] = $camera_lens_id;
        $result['report_id'] = $camera_id.'-'.$camera_lens_id;
        $result['cameraModel_id'] = $cameraModel_id;
        $result['uploaded_at'] = $time;
        $result['checked_at'] = $time;
        $result['cloud_user_id'] = $user->userId;
        if(!empty($qualified))
            $result['qualified'] = $qualified;
        else
            $result['qualified'] = false;
        
        if(!empty($uas_serial_id)){
            $sql = "select id from plane where uas_serial_id = '$uas_serial_id'";
            $plane_id = $this->fetchColumn($sql);
            
            if($plane_id){
                $result['plane_id'] = $plane_id;
            }
        }        
        
        file_put_contents("./log_" . date("Y-m-d") . ".txt","\n".date("H:i:s", time()).':'.__METHOD__.':'."edit :".json_encode($_POST)."\r\n", FILE_APPEND);
        
        if (is_uploaded_file ( $_FILES ['checkResult'] ['tmp_name'] )) {
            $allowedExts = array (
                    "txt"
            );
            $extension = end ( explode ( ".", $_FILES ["checkResult"] ["name"] ) );
            if ($extension == "txt") {                
                $lines = file($_FILES ['checkResult'] ['tmp_name'], 2);
                
                file_put_contents("./log_" . date("Y-m-d") . ".txt","\n".date("H:i:s", time()).':'.__METHOD__.':'."line:".json_encode($lines)."\r\n", FILE_APPEND);
                
                foreach($lines as $line){
                    list($key, $value) = explode("=", $line);
                    $results[$key] = $value;
                }
                //print_r($results);exit();
                if($results["f"] < 1){
                    echo "数据格式错误。";exit();
                }
                $result['report_id'] = $camera_id."-".$camera_lens_id;
                $result['image_width'] = $results["wid"];
                $result['image_height'] = $results["hei"];
                $result['dpi'] = $results["dpi"];
                $result['x0'] = $results["xo"];
                $result['y0'] = $results["yo"];
                $result['f'] = $results["f"];
                $result['k1'] = $results["K1"];
                $result['k2'] = $results["K2"];
                $result['k3'] = $results["K3"];
                file_put_contents("./log_" . date("Y-m-d") . ".txt", "\n" . date("H:i:s", time()) . ':' . __METHOD__ . ':' . "send sms:".json_encode($results)."\r\n", FILE_APPEND);
                if(isset($results["K4"]))
                    $result['k4'] = $results["K4"];
                else
                    $result['k4'] = 0;
                if(isset($results["K5"]))
                    $result['K5'] = $results["K5"];
                else
                    $result['K5'] = 0;
                if(isset($results["K6"]))
                    $result['K6'] = $results["K6"];
                else
                    $result['K6'] = 0;
                $result['p1'] = $results["P1"];
                $result['p2'] = $results["P2"];
                $result['alpha'] = $results["A"];
                $result['beta'] = $results["B"];
                
            }else{
                $this->returnError('检校结果文件类型错误');
            }
        }
        
        if(!empty($this->getPost("picture1_url"))){
            $result['picture1_url'] = $this->getPost("picture1_url");
        }
        
        if(!empty($this->getPost("picture2_url"))){
            $result['picture2_url'] = $this->getPost("picture2_url");
        }
        
        if(!empty($this->getPost("picture3_url"))){
            $result['picture3_url'] = $this->getPost("picture3_url");
        }
        
        if(!empty($this->getPost("checkProjectFile"))){
            $result['check_project_url'] = $this->getPost("checkProjectFile");
        }
        
        if(!empty($this->getPost("calibrationResultFile"))){
            $result['calibration_result_url'] = $this->getPost("calibrationResultFile");
        }
        
        $result['is_checked'] = true;
        
        $this->update('camera_check', $result,"id=$id");
        
        $this->returnSuccess("更新成功");
    }

    /******************************    出厂履历    ***********************************************************/
    public function reportFactorySetListAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $action = $this->getRequestAction();
        switch ($action) {
            case  $this::REQUEST_ACTION_DELETE: {
            };
                break;
            case  $this::REQUEST_ACTION_LIST: {
                $table = "(
SELECT F.id, plane_model.name, plane.planeModel_id, plane.uas_serial_id, camera_check.camera_id, camera_check.qualified, F.upload_user_id, F.pqc_url, F.oqc_url, F.fqc_url ,F.created_at FROM report_factory_set AS F
  LEFT JOIN plane ON F.plane_id=plane.id
  LEFT JOIN plane_model ON plane.planeModel_id=plane_model.id
  LEFT JOIN camera_check ON F.camera_check_id=camera_check.id
)";
                $this->postQueryByPage(array(
                    "id" => "ID",
                    "upload_user_id" => "上传用户id",
                    "name" => "飞机型号",
                    "uas_serial_id" => "飞机编号",
                    "camera_id" => "相机编号",
                    "qualified" => "检较结果",
                    "pqc_url" => "PQC下载链接",
                    "oqc_url" => "OQC下载链接",
                    "fqc_url" => "FQC下载链接",
                    "created_at" => "修改时间",
                ), $table
                    , array(
                        ["id", "="],
                        ["camera_id", "like", "%", "%"],
                        ["qualified", "="],
                        ["planeModel_id", "="],
                        ["upload_user_id", "="],
                        ["uas_serial_id", "like", "%", "%"],
                        ['created_at_start', '>=', '', '', "created_at"],
                        ['created_at_end', '<=', '', '', "created_at"]
                    ),"created_at desc","id");
            };
                break;
        }
        $this->view->setVars(array("planeTypeList" => $this->getPlaneModelInfo()

            )

        );
    }

    public function detailFactorySetAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->transferErrorPage("权限不足", "");
        }
        $keyId = intval($this->getQuery("id"));
        $sql = "(SELECT R.*, MO.`name` AS plane_model, plane.uas_serial_id, M.`name` AS camera_model, C.camera_lens_id, C.camera_id FROM report_factory_set AS R
            LEFT JOIN plane ON R.plane_id=plane.id
            LEFT JOIN plane_model AS MO ON plane.planeModel_id=MO.id
            LEFT JOIN camera_check AS C ON R.camera_check_id=C.id
            LEFT JOIN camera_model AS M ON C.cameraModel_id=M.id
            WHERE R.id=$keyId)";
        $this->generateDetailData(array(
            "table" => $sql,
            "column" => array(
                ["plane_model", "飞机型号", ""],
                ["uas_serial_id", "飞机编号", ""],
                ["fuselage_no", "机身编号", ""],
                ["left_wing_no", "左机翼编号", ""],
                ["right_wing_no", "右机翼编号", ""],
                ["left_empennage_no", "左V尾编号", ""],
                ["camera_model", "相机型号", ""],
                ["camera_lens_id", "相机镜头编号", ""],
                ["camera_id", "相机机身编号", ""],
                ["radio_no", "电台ID", ""],
                ["uas_board_no", "飞控版编号", ""],
                ["uas_hardware_ver", "飞控硬件版本号", ""],
                ["uas_firmware_ver", "飞控固件版本号", ""],
                ["power_board_no", "电源版编号", ""],
                ["power_board_hardware_ver", "电源板硬件版本号", ""],
                ["power_board_firmware_ver", "电源板固件版本号", ""],
                ["plane_radio_no", "机载数传电台编号", ""],
                ["plane_radio_hardware_ver", "机载数传电台硬件版本号", ""],
                ["plane_radio_firmware_ver", "机载数传电台固件版本号", ""],
                ["floor_radio_no", "地面数传电台编号", ""],
                ["floor_radio_hardware_ver", "地面数传电台硬件版本号", ""],
                ["floor_radio_firmware_ver", "地面数传电台固件版本号", ""],
                ["gps_board_no", "GPS板编号", ""],
                ["gps_board_hardware_ver", "GPS板硬件版本号", ""],
                ["battery_no", "智能电池编号", ""],
                ["backup_battery_no", "备用智能电池编号", ""],
                ["battery_firmware_ver", "智能电池固件版本号", ""],
                ["key_no", "加密狗编号", ""],
                ["key_ver", "加密狗版本号", ""],
                ["charger_no", "充电器编号", ""],
                ["engine_no", "电机编号", ""],
                ["regulator_no", "电调编号", ""],
                ["left_wing_steer_no", "左机翼舵机编号", ""],
                ["right_wing_steer_no", "右机翼舵机编号", ""],
                ["left_empennage_steer_no", "左V尾舵机编号", ""],
                ["right_empennage_steer_no", "右V尾舵机编号", ""],
                ["parachute_steer_no", "伞舱舵机编号", ""],
                ["boot_loader_ver", "bootLoader版本号", ""],
                ["plane_rework", "返修记录", ""],
                ["pqc_url", "PQC下载链接", ""],
                ["oqc_url", "OQC下载链接", ""],
                ["fqc_url", "FQC下载链接", ""],
                ["upload_user_id", "最后修改用户", ""],
                ["created_at", "创建时间", ""],
                ["id", "", "", false],
            ),
            "title" => "ID",
            "titleKey" => "id",
            "keyName" => "id",
            "where" => "id=$keyId",
        ));

    }

    /******************************    飞行检查    ***********************************************************/
    public function reportFlightCheckAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $action = $this->getRequestAction();
        switch ($action) {
            case  $this::REQUEST_ACTION_DELETE: {
            };
                break;
            case  $this::REQUEST_ACTION_LIST: {
                $table = "(
SELECT R.id, R.upload_user_id, plane.uas_serial_id, R.attachment_url, R.log_url, R.created_at FROM report_flight_check AS R
LEFT JOIN plane ON R.plane_id=plane.id
)";
                $this->postQueryByPage(array(
                    "id" => "ID",
                    "upload_user_id" => "上传用户id",
                    "uas_serial_id" => "飞机编号",
                    "attachment_url" => "飞行检查表",
                    "log_url" => "飞行日志",
                    "created_at" => "更新时间",
                ), $table
                    , array(
                        ["id", "="],
                        ["uas_serial_id", "like", "%", "%"],
                        ['created_at_start', '>=', '', '', "created_at"],
                        ['created_at_end', '<=', '', '', "created_at"]
                    ),"created_at desc","id");
            };
                break;
        }
        $this->view->setVars(array("planeTypeList" => $this->getPlaneModelInfo()

            )

        );
    }

    /******************************    交付记录    ***********************************************************/
    public function reportDeliveryRecordAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $action = $this->getRequestAction();
        switch ($action) {
            case  $this::REQUEST_ACTION_DELETE: {
            };
                break;
            case  $this::REQUEST_ACTION_LIST: {
                $table = "(
SELECT R.*, plane.uas_serial_id FROM report_delivery_record AS R
LEFT JOIN plane ON R.plane_id=plane.id
)";
                $this->postQueryByPage(array(
                    "id" => "ID",
                    "upload_user_id" => "提交用户id",
                    "uas_serial_id" => "飞机编号",
                    "delivery_location" => "交付地点",
                    "company" => "单位名称",
                    "phone" => "电话(管理用ID)",
                    "buyer" => "接收方代表",
                    "sales_office" => "销售处名称",
                    "sales_man" => "销售代表",
                    "created_at" => "交付时间",
                ), $table
                    , array(
                        ["id", "="],
                        ["upload_user_id", "="],
                        ["uas_serial_id", "like", "%", "%"],
                        ["delivery_location", "like", "%", "%"],
                        ["company", "like", "%", "%"],
                        ["phone", "like", "%", "%"],
                        ['created_at_start', '>=', '', '', "created_at"],
                        ['created_at_end', '<=', '', '', "created_at"]
                    ),"created_at desc","id");
            };
                break;
        }
        $this->view->setVars(array("planeTypeList" => $this->getPlaneModelInfo()

            )

        );
    }

    public function detailDeliveryRecordAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->transferErrorPage("权限不足", "");
        }
        $keyId = intval($this->getQuery("id"));
        $sql = "(SELECT R.*, plane.uas_serial_id FROM report_delivery_record AS R
LEFT JOIN plane ON R.plane_id=plane.id
WHERE R.id=$keyId)";
        $this->generateDetailData(array(
            "table" => $sql,
            "column" => array(
                ["uas_serial_id", "飞机编号", ""],
                ["delivery_at", "交付时间", ""],
                ["delivery_location", "交付地点", ""],
                ["company", "单位名称", ""],
                ["company_addr", "单位地址", ""],
                ["phone", "电话(管理用ID)", ""],
                ["comment", "交付内容", ""],
                ["buyer", "接收方代表", ""],
                ["sales_office", "销售处名称", ""],
                ["sales_man", "销售代表", ""],
                ["created_at", "创建时间", ""],
                ["id", "", "", false],
            ),
            "title" => "ID",
            "titleKey" => "id",
            "keyName" => "id",
            "where" => "id=$keyId",
        ));
    }

    /******************************    维修记录    ***********************************************************/
    public function reportFixRecordAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->returnError($this->lstr("OPERATION_AUTH_ERROR"));
        }
        $action = $this->getRequestAction();
        switch ($action) {
            case  $this::REQUEST_ACTION_DELETE: {
            };
                break;
            case  $this::REQUEST_ACTION_LIST: {
                $table = "(
SELECT R.*, plane.uas_serial_id ,IF(R.quality_time>=NOW(), '1','0') AS isquality FROM report_fix_record AS R
LEFT JOIN plane ON R.plane_id=plane.id
)";
                $this->postQueryByPage(array(
                    "id" => "ID",
                    "upload_user_id" => "修改用户id",
                    "uas_serial_id" => "飞机编号",
                    "delivery_at" => "交付时间",
                    "fix_at" => "维修时间",
                    "quality_time" => "质保到期时间",
                    "accident_report_url" => "事故报告",
                    "accident_record_url" => "事故日志",
                    "fix_record_url" => "工厂维修记录表",
                    "oqc_url" => "OQC检验单",
                    "flight_test_url" => "维修试飞报告",
                    "created_at" => "最后修改时间",
                ), $table
                    , array(
                        ["id", "="],
                        ["uas_serial_id", "like", "%", "%"],
                        ["isquality", "="],
                        ['created_at_start', '>=', '', '', "created_at"],
                        ['created_at_end', '<=', '', '', "created_at"]
                    ),"created_at desc","id");
            };
                break;
        }
        $this->view->setVars(array("planeTypeList" => $this->getPlaneModelInfo()

            )

        );
    }

    public function detailFixRecordAction()
    {
        if (!$this->isMonitorAdminUser()) {
            $this->transferErrorPage("权限不足", "");
        }
        $keyId = intval($this->getQuery("id"));
        $sql = "(SELECT R.*, plane.uas_serial_id ,IF(R.quality_time>=NOW(), '是','否') AS isquality FROM report_fix_record AS R
            LEFT JOIN plane ON R.plane_id=plane.id
            WHERE R.id=$keyId)";
        $this->generateDetailData(array(
            "table" => $sql,
            "column" => array(
                ["uas_serial_id", "飞机编号", ""],
                ["accident_report_url", "事故报告", ""],
                ["accident_record_url", "事故日志", ""],
                ["fix_record_url", "工厂维修记录表", ""],
                ["oqc_url", "OQC检验单", ""],
                ["flight_test_url", "维修试飞报告", ""],
                ["delivery_at", "交付时间", ""],
                ["fix_at", "维修时间", ""],
                ["quality_time", "质保到期时间", ""],
                ["isquality", "是否在质保期内", ""],
                ["plane_status_check", "飞机状态检查", ""],
                ["plane_status_checker", "飞机状态检查员", ""],
                ["plane_status_iqc", "飞机状态质检员", ""],
                ["plane_fix", "维修情况记录", ""],
                ["plane_fixer", "维修人员", ""],
                ["plane_fix_iqc", "维修情况质检员", ""],
                ["plane_fix_result", "维修结论", ""],
                ["plane_fix_result_iqc", "维修结论质检员", ""],
                ["upload_user_id", "最后修改用户ID", ""],
                ["created_at", "最后修改时间", ""],
                ["id", "", "", false],
            ),
            "title" => "ID",
            "titleKey" => "id",
            "keyName" => "id",
            "where" => "id=$keyId",
        ));
    }

    public function filedItemChanged($table, $name, $value)
    {

        switch ($name) {
            case "is_checked": {
                return $value == "1" ? "<span style='font-weight:bold; color:#ffffff; background: #00db1c; border-radius:4px'>&nbsp;是&nbsp;</span>" : "<span style='font-weight:bold; color:#ffffff; background: #db0006; border-radius:4px'>&nbsp;否&nbsp;</span>";
            };
                break;
            case "qualified": {
                if ($value == '1'){
                    return "<span style='font-weight:bold; color:#ffffff; background: #00db1c; border-radius:4px'>&nbsp;是&nbsp;</span>";
                }elseif ($value == '0'){
                    return "<span style='font-weight:bold; color:#ffffff; background: #db0006; border-radius:4px'>&nbsp;否&nbsp;</span>";
                }
            };
                break;
            case "picture1_url": {
                return "<a href='" . $value . "'>查看图片1</a>";
            };
                break;
            case "picture2_url": {
                return "<a href='" . $value . "'>查看图片2</a>";
            };
                break;
            case "accident_report_url":
            case "accident_record_url":
            case "fix_record_url":
            case "oqc_url":
            case "flight_test_url":
            case "xml_url": {
                if($value){
                    return "<a href='" . $value . "'>下载文件</a>";
                }
            };
            case "check_project_url": {
                if($value){
                    return "<a href='" . $value . "'>下载文件</a>";
                }
            };
            case "calibration_result_url": {
                if($value){
                    return "<a href='" . $value . "'>下载文件</a>";
                }
            };
            case "word_url": {
                if($value){
                    return "<a href='" . $value . "'>下载文件</a>";
                }
            };
                break;
            case "attachment_url": {
                if($value){
                    return "<a href='" . $value . "'>下载飞行检查表</a>";
                }
            };
                break;
            case "log_url": {
                if($value){
                    return "<a href='" . $value . "'>下载飞行日志</a>";
                }
            };
                break;
        }
        return $value;
    }


}